﻿Public Class u_timkiem
    Private Sub LoadData(TenBang As String, NoiDung As String)
        Dim tk As New TimKiemBUS
        dgvTimKiem.DataSource = tk.TimKiemNV(TenBang, NoiDung)
    End Sub

    Function kiemtra() As String
        If txtTuKhoa.Text = "" Or cbxNhom.Text = "" Then
            MessageBox.Show("Không thể để trống thông tin")
            Return False
        End If
        Return True
    End Function

    Private Sub u_timkiem_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cbxNhom.Items.Add("Nhân Viên")
        cbxNhom.Items.Add("Khách Hàng")
        cbxNhom.Items.Add("Thực Đơn")
        cbxNhom.Items.Add("Hóa Đơn")
        cbxNhom.Items.Add("Nguyên Liệu")
        cbxNhom.Items.Add("Nhà Cung Cấp")
    End Sub

    Private Sub btnTimKiem_Click(sender As Object, e As EventArgs) Handles btnTimKiem.Click

        If kiemtra() = True Then
            Dim tk As New TimKiemBUS
            Dim TenBang As String = cbxNhom.SelectedItem.ToString()
            Dim NoiDung As String = txtTuKhoa.Text

            If (cbxNhom.SelectedIndex = 0) Then
                dgvTimKiem.DataSource = tk.TimKiemNV(cbxNhom.SelectedItem.ToString(), txtTuKhoa.Text)
            End If
            If (cbxNhom.SelectedIndex = 1) Then
                dgvTimKiem.DataSource = tk.TimKiemKH(cbxNhom.SelectedItem.ToString(), txtTuKhoa.Text)
            End If
            If (cbxNhom.SelectedIndex = 2) Then
                dgvTimKiem.DataSource = tk.TimKiemTD(cbxNhom.SelectedItem.ToString(), txtTuKhoa.Text)
            End If
            If (cbxNhom.SelectedIndex = 4) Then
                dgvTimKiem.DataSource = tk.TimKiemNL(cbxNhom.SelectedItem.ToString(), txtTuKhoa.Text)
            End If
            If (cbxNhom.SelectedIndex = 5) Then
                dgvTimKiem.DataSource = tk.TimKiemNhaCungCap(cbxNhom.SelectedItem.ToString(), txtTuKhoa.Text)
            End If
        End If
        'LoadData(TenBang, NoiDung)
    End Sub

    
End Class
